package app.netant.finishbook.shumi6;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;

public class Shumi6Detail extends BaseDetail {

	public Shumi6Detail(String netSite) {
		super(netSite);
		this.preHref = "https://www.shumi6.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".wrap .novel .contain .one .title");
		if(parts.size()>0){
			
			String title = parts.get(0).select("h2").get(0).text().trim();
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
			
			String writers = parts.get(0).select("span").get(0).text();
			int idx = writers.indexOf("：");
			if(idx>0){
				String writer = writers.substring(idx+1).trim();
				System.out.println("【Writer】:"+writer);
				this.entity.setNovelWriter(writer);
			}
		}
		
	}

	@Override
	public void analyseTags() {
		
		
		
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".wrap .novel .contain .one .intro_con .introCon");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}	
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".wrap .novel .contain .one .inputli a.wantElite");
		if(parts.size()>0){
			String href = parts.get(0).attr("href");
			if(href.startsWith("/")){
				href = this.preHref + href;
			}
			System.out.println("【Href】:"+href);
			this.entity.setDownPath(href);
		}else{
			throw new RuntimeException("无法获取下载地址信息........");
		}
	}
	
	@Override
	public void analyseType() {
		Elements parts = this.select(".path h2 a");
		if(parts.size()>1){
			String type = parts.get(1).text();
			System.out.println("【Type】:"+type);
			this.entity.setNovelType(type);
		}
	}
	
	public static void main(String[] args) {
		Shumi6Detail detail = new Shumi6Detail("https://www.shumi6.com/8273/");
		detail.analyseTitle();
		detail.analyseMemo();
		detail.analyseHref();
	}



}
